package com.tuanbiao.ui.plan;

import android.content.Context;
import android.content.Intent;

import com.tuanbiao.base.mvp.BasePresenterActivity;
import com.tuanbiao.controllers.PlanController;
import com.tuanbiao.databinding.ActivityDetonatorPlanSettingBinding;
import com.tuanbiao.models.PlanModel;
import com.tuanbiao.presenter.PlanSettingPresenter;

public class PlanSettingActivity extends BasePresenterActivity<PlanSettingPresenter, ActivityDetonatorPlanSettingBinding> implements PlanController.SettingView {
    public static void start(Context context) {
        Intent starter = new Intent(context, PlanSettingActivity.class);
        context.startActivity(starter);
    }

    public static Intent createIntent(Context context) {
        Intent starter = new Intent(context, PlanSettingActivity.class);
        return starter;
    }

    @Override
    protected ActivityDetonatorPlanSettingBinding getBindingView() {
        return ActivityDetonatorPlanSettingBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void initView() {
        binding.ivToolbarBack.setOnClickListener(getBackListener());
        binding.btnConfirm.setOnClickListener(view -> {
            mPresenter.setDelay(getString(binding.etStartDelay), getString(binding.etRowDelay), getString(binding.etColumnsDelay),
                    getString(binding.etF1Delay), getString(binding.etF2Delay));
        });
    }


    @Override
    protected PlanSettingPresenter createPresenter() {
        return new PlanSettingPresenter(new PlanModel(), this);
    }


    @Override
    public void showDefaultDelay(String startDelay, String rowDelay, String columnDelay) {
        binding.etStartDelay.setText(startDelay);
        binding.etRowDelay.setText(rowDelay);
        binding.etColumnsDelay.setText(columnDelay);
    }

    @Override
    public void showKeyDelay(String f1Delay, String f2Delay) {
        binding.etF1Delay.setText(f1Delay);
        binding.etF2Delay.setText(f2Delay);
    }
}